<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" >
<head>
    <meta charset="UTF-8">
    <title>收货地址页面</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>

</head>
<body>
<div class="container-fluid">
    <!--导航栏-->
<!--    <div class="row">-->
<!--        <div class="col-md-6">-->
<!--            <ul class="nav nav-pills">-->
<!--                <li role="presentation" class="active"><a href="#">Home</a></li>-->
<!--                <li role="presentation"><a href="#">Profile</a></li>-->
<!--                <li role="presentation"><a href="#">Messages</a></li>-->
<!--            </ul>-->
<!--        </div>-->
<!--    </div>-->

    <div class="row">
        <table class="table table-hover">
            <thead>
            <div class="One_ShopTop">
            <tr class="success">
                <th>请选择</th>
                <th>编号</th>
                <th>收货人名称</th>
                <th>手机号</th>
                <th>省份</th>
                <th>城市</th>
                <th>县城</th>
                <th>详细地址</th>
                <th>操作类型</th>
            </tr>

            </div>
            </thead>
             数据显示
            <tr th:each="item:${page.list}">
                <td><input type="checkbox" name="ids" th:value="${item.id}" ></td>
                <td th:text="${item.id}" th:id="${item.id}"></td>
                <td th:text="${item.username}"></td>
                <td th:text="${item.phone}"></td>
                <td th:text="${item.province}"></td>
                <td th:text="${item.city}"></td>
                <td th:text="${item.countyTown}"></td>
                <td th:text="${item.addressDetails}"></td>
                <!-- 删除按钮，使用提交表单的方式 -->
                <td>
                    <button th:id="${item.id}" th:onclick="deletePlayer(this.getAttribute('id'))">删除</button>
                    <button th:id="${item.id}" th:onclick="setDefaultAddress(this.getAttribute('id'))">设置默认地址</button>
                </td>

            </tr>
            <h2><a class="btn btn-sm btn-success" th:href="@{/doorto/address/insert}">员工添加</a></h2>
        </table>
    </div>

    <div class="order_btm">
        <div>
            <button class="btn_page" th:if="${page.currPage > 1}" th:attr="pageNum=${page.currPage - 1}">上一页</button>
            第<span th:text="${page.currPage}"> 1 </span>页
            <button class="btn_page" th:if="${page.currPage < page.totalPage}" th:attr="pageNum=${page.currPage + 1}">下一页</button>
        </div>
    </div>

</div>
<script type="text/javascript">

    //删除指定的数据
    function deletePlayer(id){
        $.ajax({
            url:"./delete/"+id,    //请求的url地址
            // dataType:"text",   //返回格式为json
            type:"GET",   //请求方式
        });
    }

    //设置默认收货地址
    function setDefaultAddress(id){
        $.ajax({
            url:"./setDefauleAddress/"+id,     //请求的URL地址
            type:"GET"                               //请求方式
        });
    }



</script>

<script>
    $('.btn_page').click(function (){
        var pageNum = $(this).attr("pageNum")
        location.href = "http://footbathdoor.com/doorto/address/addressList?pageNum=" + pageNum;
        return false;
    })
</script>
</body>
</html>